<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
</head>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Static/bootstrap/css/bootstrap.min.css">
<style>
.h1{
    padding-top: 50px;
}
.box{
          padding:15px;
          float: left;
          width: 208px;
          height: 275px;
          margin: 5px;
          margin-bottom: 20px;

      }
  .pic{
      padding: 10px;
      border: 2px solid #1d7db1;
      border-radius: 5px;
      box-shadow: 0 0 5px #ccc;
      width: 208px;
      height: 285px;
      float: left;
  }
.pic img{
    width: 184px;
    height: 266px;

}

    td{

        font-family: Arimo;
    }
    .footer{
        text-align: center;
        margin-top: 20px;
    }
    . footer p{
        color:#3F3838

    }
</style>
<body>
<div class="container" >
  <include
   file="Public/nav"/>
    <input type="hidden" value="{$FoundRecord1[0]['lost_or_pick']}" id="lost_or_pick">
<input type="hidden" value="{$FoundRecord1[0]['kind_id']}" id="kind_id">
<input type="hidden" value="{$FoundRecord1[0]['place']}" id="place1">
<input type="hidden" value="{$FoundRecord1[0]['lost_time']}" id="lost_time">
    <input type="hidden" value="{$FoundRecord1[0]['pic1']}" id="box1">
    <input type="hidden" value="{$FoundRecord1[0]['pic2']}" id="box2">
    <input type="hidden" value="{$FoundRecord1[0]['pic3']}" id="box3">
    <input type="hidden" value="{$FoundRecord1[0]['pic4']}" id="box4">
    <input type="hidden" value="{$FoundRecord1[0]['pic5']}" id="box5">
    <div class=" h1">
    <span id="h1">
        寻物启事
    </span>
    <button class="btn btn-primary" onclick="ajax('{$thing_id}')">认领</button>
        </div>
<table class="table table-hover" background="__PUBLIC__/Static/waterfall/img/101.jpg">
    <tr>
        <td> 物品名称:{$FoundRecord1[0]['name']}</td>
    </tr>
    <tr>
        <td id="kind" >物品分类:{$FoundRecord1[0]['kind_id']} </td>
    </tr>
    <tr>
        <td id="place"> 丢失地点:{$FoundRecord1[0]['place']}</td>
    </tr>
    <tr>
        <td id="time"> 丢失时间:{$FoundRecord1[0]['lost_time']}</td>
    </tr>
    <tr>
        <td> 联系方式:{$FoundRecord1[0]['contact']}</td>
    </tr>
    <tr >
        <td id="award"> 悬赏:{$FoundRecord1[0]['adward']}</td>
    </tr>
     <tr >
        <td id="addition"> 补充悬赏:{$FoundRecord1[0]['addition']}</td>
    </tr>
     <tr >
        <td> 状态:<span  id="status">{$FoundRecord1[0]['status']}</span></td>
    </tr>
    
    <tr>
        <td>详细描述:{$FoundRecord1[0]['description']}</td>
    </tr>
</table>

            <div><!--图片展示块-->
                <div class="box" id="pic1" >
                <div class="pic">
                    <a href="__PUBLIC__{$FoundRecord1[0]['pic1']}">
            <img src="__PUBLIC__{$FoundRecord1[0]['pic1']}"alt="" onerror="imgError(this);">
                    </a>
                </div>
                </div>
                <div class="box" id="pic2" >
                <div class="pic">
                    <a href="__PUBLIC__{$FoundRecord1[0]['pic2']}">
                    <img src="__PUBLIC__{$FoundRecord1[0]['pic2']}" alt="" onerror="imgError(this);">
                        </a>
                </div>
                </div>
                <div class="box" id="pic3" >
                <div class="pic">
                    <a href="__PUBLIC__{$FoundRecord1[0]['pic3']}">
                    <img src="__PUBLIC__{$FoundRecord1[0]['pic3']}" alt="" onerror="imgError(this);">
                        </a>
                </div>
                </div>
                <div class="box"id="pic4" >
                <div class="pic">
                    <a href="__PUBLIC__{$FoundRecord1[0]['pic4']}">
                    <img src="__PUBLIC__{$FoundRecord1[0]['pic4']}" alt="" onerror="imgError(this);">
                        </a>
                </div>
                </div>
                <div class="box"  id="pic5" >
                <div class="pic">
                    <a href="__PUBLIC__{$FoundRecord1[0]['pic5']}">
                    <img src="__PUBLIC__{$FoundRecord1[0]['pic5']}" alt=" " onerror="imgError(this);" >
                        </a>
                </div>
                </div>
          </div>
</div>
    <!-- Controls -->

    </div>
    <div class="footer">
         <p>红满堂工作室版权所有 盗版必究</p>
      <p>联系工作室:995746872@qq.com(bug反馈)</p>
    </div>
</body>
<script src="__STATIC__/jquery/jquery.min.js"></script>
<script src="__STATIC__/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript">
    var url="__APP__";
    var Public="__PUBLIC__";
    //对认领状态的判断
    var status=document.getElementById("status").innerHTML;
    console.log(status);
    if(status==0)
    document.getElementById("status").innerHTML='未认领';
    else
        if (status==1) 
        document.getElementById("status").innerHTML="已认领";
    var i;
    //对5张图片对应的字段进行判断，用户没有传的话就不显示
    for(i=1;i<=5;i++) {
        if (document.getElementById("box"+i).value == '/') {
            document.getElementById("pic"+i).style.display= "none";
        }
    }
    //图片加载错误处理
  function imgError(image){
    // 替换为默认图片
    image.setAttribute("src", Public+'/Img/noPicture.jpg');
}

    //ajax请求获取种类
    var request=new XMLHttpRequest();
    request.open("POST", url + "/Home/Information/ajax", true);
    request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    var kind_id=document.getElementById("kind_id").value;
    request.send("kind_id="+kind_id);
    request.onreadystatechange = function () {
        if (request.readyState == 4 && request.status == 200) {
            var txt = request.responseText;
            var data = eval("(" + txt + ")");

            document.getElementById("kind").innerHTML="物品分类:"+data;
        }
    }
    //若为招领则对页面进行修改
    if(document.getElementById("lost_or_pick").value==1) {
        document.getElementById("award").style.display="none";
        document.getElementById("addition").style.display="none";
        document.getElementById("h1").innerHTML = "寻主启事";
        document.getElementById("place").innerHTML = "捡到地点:" + document.getElementById("place1").value;
        document.getElementById("time").innerHTML = "捡到时间:" + document.getElementById("lost_time").value;
    }
    //我要认领按钮onclick对应的方法
    function ajax(thing_id)
    {
        var uid=document.getElementById("uid").value;
        console.log(uid);
        if(uid==0||uid==null)
        alert("您还没有登录,请先登录");
        else{
        if (confirm('您确定要认领吗') == true) {
            var request = new XMLHttpRequest();
            request.open("POST", url + "/Home/Information/ajax_id", true);
            request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            request.send("thing_id=" + thing_id);
        }
        request.onreadystatechange = function () {
            if (request.readyState == 4 && request.status == 200) {
                alert('认领成功');
            }
        }
    }
    }
</script>
<script type="text/javascript" src="__STATIC__/login.js"></script>

</html>